"""
@author: wg
@file: homework11_17.py
@time: 2023/11/21 21:00
"""

# 统计出现次数最多的字符，以及每个字符出现的次数都输出一下
count = max1 = 0
quchong = max2 = yasuo = ""
num = input("请输入一串字符:")
for i in num:
    if i not in quchong:
        quchong += i
for i in quchong:
    for j in num:
        if i == j:
            count += 1
    print("字符{}, 出现的次数为{}".format(i, count))
    yasuo = yasuo + i + str(count)    # 压缩重组语句
    if count > max1:
        max1 = count
        max2 = i
    count = 0
print("字符{}出现次数最多, 出现次数为{}".format(max2, max1))
# 字符串压缩
print("压缩后的字符串为", yasuo)
# 统计字符串中大写字母、小写字母、数字、其他字符的个数
count1 = count2 = count3 = count4 = 0
for i in quchong:
    if i.isupper():
        count1 += 1
    elif i.islower():
        count2 += 1
    elif i.isdigit():
        count3 += 1
    else:
        count4 += 1
print("大写字母的个数为：", count1)
print("小写字母的个数为：", count2)
print("数字的个数为：", count3)
print("其他字符的个数为：", count4)
